library(readr)
library(lubridate)
library(dplyr)
library(purrr)
library(MASS)
library(ggplot2)
library(stargazer)
set.seed(12191992)
generate_growth= function(term_length, num_stages, cal_first, cal_second, switch){
#generate growth sequence term_length long
#calibration input is c(mean_T, sd_T, df)
#switch is the index of first year of 2nd stage
#Sample calls:
#generate_growth(35, 1, c(0.07, 0.02, 31))
#generate_growth(35, 2, c(0.07, 0.02, 31), c(0.00, 0.00, 31), 5)
if (num_stages==1) {
return(growth_seq= cal_first[1] + cal_first[2]*rt(term_length, cal_first[3]))
} else {
growth_seq1= cal_first[1] + cal_first[2]*rt(switch-1, cal_first[3])
growth_seq2= cal_second[1] + cal_second[2]*rt(term_length-switch+1, cal_second[3])
}
return(c(growth_seq1, growth_seq2))
}
generate_growth_normal= function(term_length, num_stages, cal_first, cal_second, switch) {
# Generate a growth sequence term_length long (normal draws)
# Calibration input is c(mean, sd, df); df is ignored
# switch is the index of the first year of the 2nd stage
# Sample calls:
# generate_growth(35, 1, c(0.07, 0.02, 31))
# generate_growth(35, 2, c(0.07, 0.02, 31), c(0.00, 0.00, 31), 5)
if (num_stages == 1) {
return(rnorm(term_length, mean= cal_first[1], sd= cal_first[2]))
} else {
growth_seq1= rnorm(switch - 1, mean= cal_first[1], sd= cal_first[2])
growth_seq2= rnorm(term_length - switch + 1, mean= cal_second[1], sd= cal_second[2])
return(c(growth_seq1, growth_seq2))
}
}
project_funding= function(term_length, financing_amount, initial_inflow,
financing_rate, inflow_growth, treas_1yr, muni_1yr) {
#Negatives indicate outflows, positives are inflows
#Assumption construction happens in year_0, first coupon is due in year_1
#inflow_growth, treas_1yr, muni_1yr are sequences with term_length number of elements
year= seq(1, term_length)
#Coupons
payment= rep(-1*financing_rate*financing_amount, term_length)
#Add principal to the last coupon
payment[term_length]= payment[term_length] - financing_amount
#We can estimate the initial outflow at year_0, as the construction starts
#However, first inflow happens in year_1, and is year_0_inflow*(1+inflow_growth)
inflow= initial_inflow*cumprod(1 + inflow_growth)
liability= c(payment[1] + inflow[1])
#Calculate liability
for (i in 2:term_length) {
if (liability[i-1]< 0) {
liability[i]= liability[i-1]*(1 + muni_1yr[i]) + payment[i] + inflow[i]
} else {
liability[i]= liability[i-1]*(1 + treas_1yr[i]) + payment[i] + inflow[i]
}
}
return(cbind(year, payment, inflow, inflow_growth,
treas_1yr, muni_1yr, liability))
}
#Inflow growth calibration
nfl_salary_cap_growth= read_csv("Input/nfl_salary_cap_growth.csv",
col_names = FALSE)
nfl_growth_cap= c(mean(nfl_salary_cap_growth$X1),
sd(nfl_salary_cap_growth$X1),
nrow(nfl_salary_cap_growth)-2)
yearly_inflation= read_csv("Input/FPCPITOTLZGUSA.csv",
col_types = cols(observation_date = col_date(format = "%Y-%m-%d")))
yearly_inflation= mutate(yearly_inflation, year= year(observation_date))
yearly_inflation[,2]= yearly_inflation[,2]/100
yearly_inflation= filter(yearly_inflation, year>1985)
inflation_growth= c(mean(yearly_inflation$FPCPITOTLZGUSA),
sd(yearly_inflation$FPCPITOTLZGUSA),
nrow(yearly_inflation)-2)
#Treasury and Muni Yields
yield_1yr_treas= read_csv("Input/DGS1.csv", col_types = cols(observation_date = col_date(format = "%Y-%m-%d")))
yield_1yr_treas[,2]= yield_1yr_treas[,2]/100
yield_1_yr_aaa_muni= read_csv("Input/aaa_muni_1yr.csv",
col_types = cols(date = col_date(format = "%m/%d/%y")))
yield_1_yr_aaa_muni[,2]= yield_1_yr_aaa_muni[,2]/100
fi_merged= as.data.frame(left_join(yield_1_yr_aaa_muni, yield_1yr_treas, by=c("date"="observation_date")))
fi_merged$spread=  fi_merged[,2] - fi_merged[,3]
fi_merged= mutate(fi_merged, year= year(date))
aaa_muni_30yr= read_csv("Input/aaa_muni_30yr.csv",
col_types = cols(date = col_date(format = "%m/%d/%y")))
aaa_muni_30yr[,2]= aaa_muni_30yr[,2]/100
yield_1yr_treas= filter(yield_1yr_treas, year(observation_date)>1985)
run_simulations= function(nsim, nstages, nyears, normal = FALSE){
out= vector(mode= "list", length= nsim)
yield_spread_cov= cov(cbind(fi_merged$DGS1, fi_merged$spread))
#Choose the growth function
growth_fun= if (normal) generate_growth_normal else generate_growth
for (i in 1:nsim){
#Project inputs
financing_amount= 1000
financing_rate= rnorm(1, 0.045, sd(aaa_muni_30yr$yield_30yr_aaa_muni))
term_length= 35
#admissions + income + concessions (sb27 fiscal note, cap + 20% overrun, packers rev. percentage)
initial_inflow= 12 + 8 + 8.25
#First stage calibration is set to NFL salary cap
#Second stage calibration is set to inflation
inflow_growth= growth_fun(term_length, nstages, nfl_growth_cap, inflation_growth, nyears)
#Borrowing and lending rates; stock market return
fi_yields= mvrnorm(n= term_length,
c(mean(yield_1yr_treas$DGS1, na.rm= TRUE),
mean(fi_merged$spread, na.rm= TRUE)),
yield_spread_cov, tol = 1e-6,
empirical= FALSE, EISPACK= FALSE)
treas_1yr= fi_yields[,1]
muni_1yr= fi_yields[,1] + fi_yields[,2]
test_funding= as.data.frame(project_funding(term_length, financing_amount, initial_inflow,
financing_rate, inflow_growth, treas_1yr, muni_1yr))
#store initial financing rate in the last row
test_funding= rbind(test_funding, c(0,0,0,0,0,0,financing_rate))
out[[i]]= test_funding
}
return(out)
}
#Baseline -- One stage
one_stage_high_growth= run_simulations(100000, 1, 35)
library(readr)
library(lubridate)
library(dplyr)
library(purrr)
library(MASS)
library(xtable)
set.seed(12191992)
#Read treasury data and merge
merge_treasury_yields= function(maturities = c(1, 2, 3, 5, 7, 10, 30), path = "Input"){
#Reads DGS<maturity>.csv files, converts percent to decimal,
#keeps observations after 1985, merges on observation_date,
#and keeps only complete cases
read_one= function(m){
df= read_csv(file.path(path, paste0("DGS", m, ".csv")),
col_types = cols(observation_date = col_date(format = "%Y-%m-%d")))
df[,2]= df[,2]/100
df= filter(df, year(observation_date) > 1985)
df= filter(df, year(observation_date) <= 2027)
return(df)
}
merged= reduce(lapply(maturities, read_one), inner_join, by = "observation_date")
merged= merged[complete.cases(merged), ]
return(merged)
}
yield_curve_hist= merge_treasury_yields()
#Monthly equity returns: each line is YYYYMM followed by the return (decimal)
#Reads the first 6 characters as the month and the rest as the return, so it works
#whether the separator is a comma, a tab, or nothing; header and footer lines are skipped
eq_lines= trimws(readLines("Input/monthly_equity_rets.csv"))
eq_lines= eq_lines[grepl("^[0-9]{6}", eq_lines)]
eq_month= substr(eq_lines, 1, 6)
eq_ret= as.numeric(trimws(gsub("^[,;\t ]+", "", substring(eq_lines, 7))))
s_df= data.frame(month= paste0(substr(eq_month, 1, 4), "-", substr(eq_month, 5, 6)),
vwretd= eq_ret, stringsAsFactors= FALSE)
s_df= s_df[!is.na(s_df$vwretd) & as.numeric(substr(s_df$month, 1, 4)) > 1985, ]
#Convert treasuries to monthly, merge with equities for bootstrapping
DGS_COLS= c("DGS1", "DGS2", "DGS3", "DGS5", "DGS7", "DGS10", "DGS30")
y_date_col= if ("observation_date" %in% names(yield_curve_hist)) "observation_date" else "DATE"
y_dates= as.Date(yield_curve_hist[[y_date_col]])
y_month= format(y_dates, "%Y-%m")
ord= order(y_dates)
y_month_ordered= y_month[ord]
y_hist_ordered= yield_curve_hist[ord, ]
#Monthly yield = mean of all daily yields in that month, not last day
mean_or_na= function(x) if (all(is.na(x))) NA_real_ else mean(x, na.rm= TRUE)
y_monthly= aggregate(y_hist_ordered[, DGS_COLS, drop= FALSE],
by= list(month= y_month_ordered),
FUN= mean_or_na)
#aggregate sorts by month, which is chronological for "YYYY-MM"
y_monthly_month= as.character(y_monthly$month)
y_df= data.frame(month = y_monthly_month, y_monthly[, DGS_COLS, drop= FALSE], stringsAsFactors= FALSE)
boot_data_rets= merge(y_df, s_df, by= "month")
boot_data_rets= boot_data_rets[order(boot_data_rets$month), ]
#Check the sample
#range(boot_data_rets$month)
#summary(boot_data_rets$vwretd)
#Data not vwretd but Ken French market (mkt-rf, with rf added back)
#Name kept for compatibility with old data
#Monte Carlo simulation of reserve lock-in
#A reserve V0 is invested in equities. As soon as it reaches the amount that, invested in a
#zero-coupon Treasury (STRIPS) maturing at year 35, grows to the target, it is locked in.
#Equity returns and monthly par-yield changes are drawn with a paired 6-month block
#bootstrap; simulated curves start from the latest curve (or a random historical curve)
#and accumulate the changes.
#Par yields at listed maturities -> par yields at 1, 2, ..., 30 years (linear in maturity)
#par: matrix (rows = months, cols = listed maturities), mats: listed maturities (sorted)
interp_par_curve= function(par, mats, grid = 1:30){
#Linear interpolation as a weight matrix (flat beyond the end points), applied to all rows
W= matrix(0, length(mats), length(grid))
for (j in seq_along(grid)){
g= min(max(grid[j], min(mats)), max(mats))
hi= which(mats >= g)[1]
if (mats[hi] == g){ W[hi, j]= 1; next }
lo= hi - 1
w= (g - mats[lo]) / (mats[hi] - mats[lo])
W[lo, j]= 1 - w
W[hi, j]= w
}
return(par %*% W)
}
#Par curve -> STRIPS (zero-coupon) yields at 1, ..., 30, semiannual compounding
#Semiannual coupons: a par bond with j half-years satisfies 1 = (y/2) * sum(D_1..D_j) + D_j
#Par yields are interpolated to the half-year grid 0.5, 1, ..., 30 for the bootstrap
#(0.5 uses the 1-year yield), and zero yields are reported at 1, ..., 30
strips_curve= function(par, mats){
half= seq(0.5, 30, by = 0.5)
par_half= interp_par_curve(par, mats, grid = half)
D= matrix(NA_real_, nrow(par_half), length(half))
cum_D= rep(0, nrow(par_half))
for (j in seq_along(half)){
c2= par_half[, j] / 2
D[, j]= (1 - c2 * cum_D) / (1 + c2)
cum_D= cum_D + D[, j]
}
Z_half= sweep(D, 2, 2 * half, function(d, n) 2 * (d^(-1 / n) - 1))
return(Z_half[, half %in% 1:30, drop = FALSE])
}
#STRIPS yield for remaining maturity R (years) from a zero curve at 1, ..., 30
#R <= 1 uses the 1-year yield, R >= 30 the 30-year yield, integer R the listed yield,
#otherwise linear interpolation between the two neighboring integer maturities
strips_yield= function(Z, R){
if (R <= 1) return(Z[, 1])
if (R >= 30) return(Z[, 30])
lo= floor(R)
hi= ceiling(R)
if (lo == hi) return(Z[, lo])
w= R - lo
return(Z[, lo] + w * (Z[, hi] - Z[, lo]))
}
#Threshold: cost of the lock-in portfolio with R years left
#A regular Treasury bought at par with face F = target * coupon / par yield(R) matches the
#remaining coupons; a STRIPS with face target - F covers the rest of the principal.
#If F >= target, no STRIPS is bought and the threshold is F.
#lockin = 1: coupons and principal (as above); lockin = 2: a STRIPS for the target only
#par: par yields at listed maturities (rows = curves), Z: STRIPS curve at 1, ..., 30
threshold= function(par, mats, Z, R, target, coupon, lockin = 1){
y= strips_yield(Z, R)
if (lockin == 2) return(target / (1 + y / 2)^(2 * R))
y_par= as.vector(interp_par_curve(par, mats, grid = min(max(R, 1), 30)))
F= target * coupon / y_par
strips_face= pmax(target - F, 0)
return(F + strips_face / (1 + y / 2)^(2 * R))
}
simulate_lockin= function(data, V0_list, target = 1000, horizon_years = 35,
n_sim = 50000, block_months = 6, seed = NULL, coupon, lockin = 1,
start_curve = "latest", coupon_mult = NULL,
yield_floor = 0.0001){
if (!is.null(seed)) set.seed(seed)
#Keep complete months, in chronological order
data= data[complete.cases(data), ]
data= data[order(data$month), ]
yield_cols= grep("^DGS[0-9]+$", names(data), value = TRUE)
mats= as.numeric(sub("DGS", "", yield_cols))
ord= order(mats)
yield_cols= yield_cols[ord]
mats= mats[ord]
par= as.matrix(data[, yield_cols])
#Monthly changes in par yields, paired with the same month's equity return
dpar= diff(par)
rets= data$vwretd[-1]
N= nrow(dpar)
n_months= horizon_years * 12
#Starting curve: the most recent month in the data (start_curve = "latest"), a historical
#month drawn at random for each path (start_curve = "random"), or a supplied curve
#(numeric vector of par yields in decimals, one per listed maturity, e.g. today's curve)
par_lev= pmax(par, yield_floor)
if (is.numeric(start_curve)){
if (length(start_curve) != length(mats)) stop("start_curve needs one yield per maturity: ", paste(mats, collapse = ", "))
par0= matrix(pmax(start_curve, yield_floor), n_sim, length(mats), byrow = TRUE)
} else {
idx0= if (start_curve == "random") sample.int(nrow(par), n_sim, replace = TRUE) else rep(nrow(par), n_sim)
par0= par_lev[idx0, , drop = FALSE]
}
#Coupon: a fixed input, or coupon_mult times each path's starting 30-year par yield
if (!is.null(coupon_mult)) coupon= coupon_mult * par0[, mats == 30]
coupon= rep_len(coupon, n_sim)
thr0= threshold(par0, mats, strips_curve(par0, mats), horizon_years, target, coupon, lockin)
#Paired block bootstrap: block starts uniform over all N months, with replacement
#Blocks that run past the last month wrap around to the first (circular)
n_blocks= ceiling(n_months / block_months)
starts= matrix(sample.int(N, n_sim * n_blocks, replace = TRUE), n_sim, n_blocks)
K= length(V0_list)
V= matrix(rep(V0_list, each = n_sim), n_sim, K)
hit_month= matrix(NA_integer_, n_sim, K)
#Month 0 lock-in against each path's starting curve
for (k in 1:K) hit_month[V0_list[k] >= thr0, k]= 0L
#Simulated par curves: starting curve plus cumulative sampled changes, floored
cur= par0
for (m in 1:n_months){
b= (m - 1) %/% block_months + 1
offset= (m - 1) %% block_months
idx= (starts[, b] - 1 + offset) %% N + 1
cur= cur + dpar[idx, , drop = FALSE]
g= 1 + rets[idx]
open_any= rowSums(is.na(hit_month)) > 0
if (!any(open_any)) break
if (m == n_months){
#Final month: principal plus the last coupon (lockin = 1) or principal only (lockin = 2)
thr_m= if (lockin == 1) target * (1 + coupon / 2) else rep(target, n_sim)
} else {
thr_m= rep(NA_real_, n_sim)
par_m= pmax(cur[open_any, , drop = FALSE], yield_floor)
thr_m[open_any]= threshold(par_m, mats, strips_curve(par_m, mats),
(n_months - m) / 12, target, coupon[open_any], lockin)
}
for (k in 1:K){
open= is.na(hit_month[, k])
if (!any(open)) next
V[open, k]= V[open, k] * g[open]
newly= open & V[, k] >= thr_m
hit_month[newly, k]= m
}
}
res= do.call(rbind, lapply(1:K, function(k){
h= hit_month[, k]
p420= mean(!is.na(h))
p360= mean(!is.na(h) & h <= 360)
p300= mean(!is.na(h) & h <= 300)
p240= mean(!is.na(h) & h <= 240)
p180= mean(!is.na(h) & h <= 180)
p120= mean(!is.na(h) & h <= 120)
p60= mean(!is.na(h) & h <= 60)
p0= mean(!is.na(h) & h == 0)
#Never locked but finished at or above target (zero by construction, since the
#final-month threshold exceeds the target)
p_fin= mean(is.na(h) & V[, k] >= target)
data.frame(V0 = V0_list[k],
start_threshold = median(thr0),
start_threshold_p10 = unname(quantile(thr0, 0.10)),
start_threshold_p90 = unname(quantile(thr0, 0.90)),
coupon_median = median(coupon),
share_by_420 = p420,
share_by_360 = p360,
share_by_300 = p300,
share_by_240 = p240,
share_by_180 = p180,
share_by_120 = p120,
share_by_60 = p60,
share_by_0 = p0,
median_hit_month = if (any(!is.na(h))) median(h, na.rm = TRUE) else NA,
share_hit_final_month = mean(!is.na(h) & h == n_months),
share_finish_above_no_lock = p_fin)
}))
return(res)
}
#SB 27 filing date 02/23/2026:
#Par curve on a given date (or the last date on or before it with all maturities)
curve_on_date= function(date, maturities = c(1, 2, 3, 5, 7, 10, 30), path = "Input"){
read_one= function(m){
df= read_csv(file.path(path, paste0("DGS", m, ".csv")),
col_types = cols(observation_date = col_date(format = "%Y-%m-%d")))
df[,2]= df[,2]/100
return(df)
}
merged= reduce(lapply(maturities, read_one), inner_join, by = "observation_date")
merged= merged[complete.cases(merged), ]
merged= filter(merged, observation_date <= as.Date(date))
last= merged[which.max(merged$observation_date), ]
print(last)
return(as.numeric(last[1, paste0("DGS", maturities)]))
}
y_0223= curve_on_date("2026-02-23")
#lockin: 1 coupons and principal, 2 STRIPS for the target only
#start_curve: "latest" (most recent curve in the data), "random" (historical curve drawn for
#each path), or a numeric vector of par yields for 1, 2, 3, 5, 7, 10, 30 years (decimals)
#coupon_mult: if set, the coupon is coupon_mult times each path's starting 30-year par yield
#(overrides coupon), e.g. coupon_mult= 0.8 with start_curve= "random"
simulate_one_stage= simulate_lockin(boot_data_rets,
V0_list= c(25, 50, 75, 100, 125, 150, 175),
target= 1000,
horizon_years= 35,
n_sim= 50000,
block_months= 36,
seed= 12191992,
coupon= 0.045,
lockin= 2,
start_curve= y_0223)
